Skip to content

Instantly share code, notes, and snippets.

@Dyrr
Created March 8, 2016 02:03
Show Gist options
  • Save Dyrr/0b4240298dfa4194639e to your computer and use it in GitHub Desktop.
Save Dyrr/0b4240298dfa4194639e to your computer and use it in GitHub Desktop.
Veloce esempio di array_map() per fixare il problema del magic_quotes_gpc() disabilitato
<?php
function filter_in($str)
{
return addslashes(str_replace('\\','',$str));
}
//ho creto apposta un array $_GET fasullo per mostrare come funziona la funziona array_map();
$_GET = array(
'test1' => "nell'anima",
'test2' => 'Pippo "Super" User'
);
$_GET = array_map('filter_in',$_GET);
print_r($_GET);
?>
/** output
Array
(
[test1] => nell\'anima
[test2] => Pippo \"Super\" User
)
*/
@Dyrr
Copy link
Author

Dyrr commented Mar 8, 2016

L'esempio come gia detto altrove vuole essere un suggerimento per un fix TEMPORANEO al problema in attesa che chi si trovi in quelle condizioni sistemi il codice nel metodo corretto ovvero usando funzioni apposite per l'escape dei caratteri per l'inserimento nel database come mysql_real_escape_string(), o mysqli_real_escape_string() nelle singole query

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment